home *** CD-ROM | disk | FTP | other *** search
/ Inside Mac Games Volume 5 #3 / IMG 46 Vol 5-3.iso / More Goodies / More For Your Game / Realmz / Character Master Source / Character Master / character class.h < prev    next >
Text File  |  1996-07-15  |  10KB  |  368 lines

  1. //•••••••••••••••••••••••••••
  2. //•    Written by David Wagner    •
  3. //•    -----------------------    •
  4. //•      Created: 1 Jun 1996    •
  5. //•••••••••••••••••••••••••••
  6.  
  7. #ifndef _CHARACTERCLASS_    // Check to make sure this is only included once
  8.     #define _CHARACTERCLASS_
  9.     
  10. #include "nemesis dialogs.h"
  11. #include "nemesis dialog class.h"
  12. #include "my files.h"
  13.  
  14. //•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  15. // Constants to access the arrays
  16. enum
  17. {
  18.     kFirstSaveVs = 0,            kLastSaveVs = 7,
  19.     kFirstSpecialAbility = 0,    kLastSpecialAbility = 7,
  20.     kFirstCondition = 0,        kLastCondition = 39,
  21.     kFirstLevel = 0,            kLastLevel = 6,
  22.     kFirstSpell = 0,            kLastSpell = 11
  23. };
  24.  
  25. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  26. //    Item lists for dialogs
  27. enum
  28. {
  29.     kEditCharacterDialogID    = 130,
  30.     kFirstECTE    = 1,
  31.     kLastECTE    = 33,
  32.     diEditGoodConditions    = 34,
  33.     diEditBadConditions,
  34.     diEditSpells,
  35.     diEditSpecialInfo,
  36.     diEditSpecialAbilities,
  37.     kNumOutlines = 13,
  38.     diType        = 39,
  39.     diRace,
  40.     diReligion,
  41.     diGender
  42. };
  43.  
  44. const    int    kECOutline[kNumOutlines] = { 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103 };
  45.  
  46. enum
  47. {
  48.     kEditSpecialAbilitiesID    = 131,
  49.     kFirstSATE    = 3,
  50.     kLastSATE    = 10,
  51.     kSADefault    = 19
  52. };
  53.  
  54. enum
  55. {
  56.     kEditSpecialInfoID = 132,
  57.     kFirstSITE    = 3,
  58.     kLastSITE    = 16,
  59.     kSIDefault    = 43,
  60.     kSIPopup    = 47
  61. };
  62.  
  63. enum
  64. {
  65.     kEditGoodConditionsID = 133,
  66.     kFirstGCTE    = 4,
  67.     kLastGCTE    = 27,
  68.     kFirstGCCheck    = 28,
  69.     kLastGCCheck    = 51,
  70.     kGCDefault    = 76,
  71.     kGCOutline1    = 77,
  72.     kGCOutline2    = 78,
  73.     kGCMagicButton = 3
  74. };
  75.  
  76. enum
  77. {
  78.     kEditBadConditionsID = 134,
  79.     kFirstBCTE    = 4,
  80.     kLastBCTE    = 19,
  81.     kFirstBCCheck    = 20,
  82.     kLastBCCheck    = 35,
  83.     kBCDefault    = 52,
  84.     kBCOutline1    = 53,
  85.     kBCOutline2    = 54,
  86.     kBCMagicButton = 3
  87. };
  88.  
  89. enum
  90. {
  91.     kEditSpellsID = 135,
  92.     kFirstSRadio    = 3,
  93.     kLastSRadio        = 9,
  94.     kFirstSCheck    = 10,
  95.     kLastSCheck        = 21,
  96.     kSDefault    = 22,
  97.     kSOutline1    = 23,
  98.     kSOutline2    = 24,
  99.     kSOutline3    = 28,
  100.     kSMagicButton = 26,
  101.     kSDescText    = 27
  102. };
  103.  
  104. const    int theGoodCondition[24] = {    4,    7,    8,    10,    11,    12,
  105.                                         13,    14,    15,    16,    17,    18,
  106.                                         19,    20,    21,    22,    23,    24,
  107.                                         30,    31,    32,    33,    35,    38    };
  108. const    int    theBadCondition[16]  = {    0,    1,    2,    3,
  109.                                         5,    6,    9,    25,
  110.                                         26,    27,    28,    29,
  111.                                         34,    36,    37,    39    };
  112. enum
  113. {
  114.     kFirstGC    = 0,
  115.     kLastGC        = 23,
  116.     kFirstBC    = 0,
  117.     kLastBC        = 15
  118. };
  119.  
  120. // Limits for values
  121. enum
  122. {
  123.     kSInt8Min    = -100,
  124.     kSInt8Max    = 110,
  125.     
  126.     kSInt16Min    = -30000,
  127.     kSInt16Max    = 30000,
  128.     
  129.     kSInt32Min    = -2000000000,
  130.     kSInt32Max    = 2000000000,
  131.     
  132.     kStatMin    = 3,
  133.     kStatMax    = 25,
  134.     
  135.     kNameMin    = 1,
  136.     kNameMax    = 19,
  137.     
  138.     kLevelMin    = 1,
  139.     kLevelMax    = 50,
  140.     
  141.     kCashMin    = 0,
  142.     
  143.     kConditionsMin = -100,
  144.     kConditionsMax = 100,
  145.     
  146.     kBaseMovementMax = 22
  147. };
  148.  
  149. //•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  150. //•    Start of character class definition                            •
  151. //•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  152. class    character
  153. {
  154.     protected:
  155.         Boolean    spellCaster, beenSaved;
  156.         FSSpec    theFileSpec;
  157.         // Variables to hold character info
  158.         CharacterFile    theCharacter;
  159.         Str255    theName;
  160.  
  161.     public:
  162.         long    editDialog;
  163.                 character();
  164.                 character( FSSpec const &, DialogRef );
  165.         CharacterFile    TheCharacter()                    { return theCharacter; };
  166.         void    SetTheCharacter( CharacterFile theC )    { theCharacter = theC; };
  167.         
  168.         OSErr    OpenCharacter();
  169.         void    CheckCharacterValues();
  170.         OSErr    OpenCharacter( FSSpec const & );
  171.         OSErr    DoSaveCharacter();
  172.         OSErr    SaveCharacter();
  173.         OSErr    RevertCharacter();
  174.         void    TransferValues();
  175.         void    SetSaved( Boolean theB )    { beenSaved = theB; };
  176.         Boolean    BeenSaved()                    { return beenSaved;    };
  177.         Boolean    SpellCaster()                { return spellCaster; };
  178.         FSSpec    TheFileSpec()                { return theFileSpec; };
  179.         
  180.         void    SetupENDialogControls();
  181.         void    FixPopups();
  182.         friend    class    editCharacterDialog;
  183. };
  184.  
  185. //•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  186. //•    End of character class definition                            •
  187. //•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  188. class    editCharacterDialog:public baseModelessDialog
  189. {
  190.     private:
  191.     int        lastItemHit;
  192.     int        lastETItemHit;
  193.     Boolean    nameWarning;
  194.     
  195.     public:
  196.     editCharacterDialog():baseModelessDialog( nil, nil, nil, nil )
  197.     {
  198.         lastItemHit = 0;
  199.         lastETItemHit = 1;
  200.         nameWarning = true;
  201.     };
  202.     editCharacterDialog( DialogRef theD, DialogRef theP )
  203.         :baseModelessDialog( theD, nil, theP, nil )
  204.     {
  205.         lastItemHit = 0;
  206.         lastETItemHit = 1;
  207.         nameWarning = true;
  208.     };
  209.     void    DoItemHit( EventRecord *, int );
  210.     void    DoUpdateMenus();
  211.     Boolean    CheckValues();
  212.     OSErr    DoHandleMenu( long );
  213.     void    DoSelectAll()    { NemesisSelectItemText( thisDialog, lastETItemHit ); };
  214.     void    DoActivate( EventRecord * theEvent )
  215.     {
  216.         baseDialog::DoActivate( theEvent );
  217.         
  218.         if( !(((character *)dialogData)->SpellCaster()) )
  219.         {
  220.             NemesisDimControl( thisDialog, 36 );
  221.         }
  222.     };
  223.     OSErr    DoClose();
  224.             
  225.     OSErr    DoSADialog();
  226.     OSErr    DoSIDialog();
  227.     OSErr    DoGCDialog();
  228.     OSErr    DoBCDialog();
  229.     OSErr    DoSDialog();
  230. };
  231.  
  232. class    editSpecialAbilitiesDialog:public baseMovableDialog
  233. {
  234.     private:
  235.     int        lastItemHit;
  236.     int        lastETItemHit;
  237.     CharacterFile    temporaryCharacter;
  238.     Boolean *nothingChanged;
  239.     Boolean    origNothingChanged;
  240.  
  241.     public:
  242.     editSpecialAbilitiesDialog():baseMovableDialog() { lastItemHit = kFirstSATE; lastETItemHit = kFirstSATE; };
  243.     editSpecialAbilitiesDialog( DialogRef thisD, WindowRef parentW ): baseMovableDialog( thisD, parentW )
  244.     { lastItemHit = kFirstSATE; lastETItemHit = kFirstSATE; };
  245.     void    SetupCharPtr( CharacterFilePtr theC )
  246.     { dialogData = (long)theC; temporaryCharacter = *((CharacterFilePtr)dialogData); };
  247.     void    SetupSaved( Boolean * theB ) { nothingChanged = theB; origNothingChanged = *theB;    };
  248.     void    DoItemHit( EventRecord *, int );
  249.     void    DoSelectAll()    { NemesisSelectItemText( thisDialog, lastETItemHit ); };
  250.     void    DoUpdateMenus();
  251.     void    SetupDialog();
  252.     Boolean    CheckValues();
  253.     void    TransferValues();
  254. };
  255.  
  256. class    editSpecialInfoDialog:public baseMovableDialog
  257. {
  258.     private:
  259.     int        lastItemHit;
  260.     int        lastETItemHit;
  261.     CharacterFile    temporaryCharacter;
  262.     Boolean *nothingChanged;
  263.     Boolean    origNothingChanged;
  264.  
  265.     public:
  266.     editSpecialInfoDialog():baseMovableDialog() { lastItemHit = kFirstSITE; lastETItemHit = kFirstSITE; };
  267.     editSpecialInfoDialog( DialogRef thisD, WindowRef parentW ): baseMovableDialog( thisD, parentW )
  268.     { lastItemHit = kFirstSITE; lastETItemHit = kFirstSITE; };
  269.     void    SetupCharPtr( CharacterFilePtr theC )
  270.     { dialogData = (long)theC; temporaryCharacter = *((CharacterFilePtr)dialogData); };
  271.     void    SetupSaved( Boolean * theB ) { nothingChanged = theB; origNothingChanged = *theB;    };
  272.     void    DoItemHit( EventRecord *, int );
  273.     void    DoSelectAll()    { NemesisSelectItemText( thisDialog, lastETItemHit ); };
  274.     void    DoUpdateMenus();
  275.     void    SetupDialog();
  276.     Boolean    CheckValues();
  277.     void    TransferValues();
  278. };
  279.  
  280. class    editGoodConditionsDialog:public baseMovableDialog
  281. {
  282.     private:
  283.     int        lastItemHit;
  284.     int        lastETItemHit;
  285.     CharacterFile    temporaryCharacter;
  286.     Boolean *nothingChanged;
  287.     Boolean    origNothingChanged;
  288.  
  289.     public:
  290.     editGoodConditionsDialog():baseMovableDialog() { lastItemHit = kFirstGCTE; lastETItemHit = kFirstGCTE; };
  291.     editGoodConditionsDialog( DialogRef thisD, WindowRef parentW ): baseMovableDialog( thisD, parentW )
  292.     { lastItemHit = kFirstGCTE; lastETItemHit = kFirstGCTE; };
  293.     void    SetupCharPtr( CharacterFilePtr theC )
  294.     { dialogData = (long)theC; temporaryCharacter = *((CharacterFilePtr)dialogData); };
  295.     void    SetupSaved( Boolean * theB ) { nothingChanged = theB; origNothingChanged = *theB;    };
  296.     void    DoItemHit( EventRecord *, int );
  297.     void    DoSelectAll()    { NemesisSelectItemText( thisDialog, lastETItemHit ); };
  298.     void    DoUpdateMenus();
  299.     void    SetupDialog();
  300.     Boolean    CheckValues();
  301.     void    TransferValues();
  302.     void    MagicButton();
  303.     void    AntiMagicButton();
  304. };
  305.  
  306. class    editBadConditionsDialog:public baseMovableDialog
  307. {
  308.     private:
  309.     int        lastItemHit;
  310.     int        lastETItemHit;
  311.     CharacterFile    temporaryCharacter;
  312.     Boolean *nothingChanged;
  313.     Boolean    origNothingChanged;
  314.  
  315.     public:
  316.     editBadConditionsDialog():baseMovableDialog() { lastItemHit = kFirstBCTE; lastETItemHit = kFirstBCTE; };
  317.     editBadConditionsDialog( DialogRef thisD, WindowRef parentW ): baseMovableDialog( thisD, parentW )
  318.     { lastItemHit = kFirstBCTE; lastETItemHit = kFirstBCTE; };
  319.     void    SetupCharPtr( CharacterFilePtr theC )
  320.     { dialogData = (long)theC; temporaryCharacter = *((CharacterFilePtr)dialogData); };
  321.     void    SetupSaved( Boolean * theB ) { nothingChanged = theB; origNothingChanged = *theB;    };
  322.     void    DoItemHit( EventRecord *, int );
  323.     void    DoSelectAll()    { NemesisSelectItemText( thisDialog, lastETItemHit ); };
  324.     void    DoUpdateMenus();
  325.     void    SetupDialog();
  326.     Boolean    CheckValues();
  327.     void    TransferValues();
  328.     void    MagicButton();
  329.     void    AntiMagicButton();
  330. };
  331.  
  332. class    editSpellsDialog:public baseMovableDialog
  333. {
  334.     private:
  335.     CharacterFile    temporaryCharacter;
  336.     Boolean *nothingChanged;
  337.     Boolean    origNothingChanged;
  338.     int        lastBoxClicked;
  339.  
  340.     public:
  341.     void    SetLastBoxClicked( int );
  342.     void    DrawDescription();
  343.     editSpellsDialog():baseMovableDialog()
  344.     {
  345.         lastBoxClicked = kFirstSCheck;
  346.     };
  347.     editSpellsDialog( DialogRef thisD, WindowRef parentW ): baseMovableDialog( thisD, parentW )
  348.     {
  349.         lastBoxClicked = kFirstSCheck;
  350.     };
  351.     void    SetupCharPtr( CharacterFilePtr theC )
  352.     { dialogData = (long)theC; temporaryCharacter = *((CharacterFilePtr)dialogData); };
  353.     void    SetupSaved( Boolean * theB ) { nothingChanged = theB; origNothingChanged = *theB;    };
  354.     void    DoItemHit( EventRecord *, int );
  355.     void    SetupSpellNames();
  356.     void    DoUpdateMenus();
  357.     void    SetupDialog();
  358.     void    TransferValues();
  359.     void    MagicButton();
  360.     void    AntiMagicButton();
  361.     void    DoActivate( EventRecord * );
  362. };
  363. //•••••••••••••••••••••••••••••••••••••••••••••••••••••••
  364. // Prototypes
  365. template<class T>
  366. void    Squash( T &, long, long );
  367.  
  368. #endif